package Object;
//要连接Cloneable，才能正常使用clong方法
public class Student implements Cloneable{
    private  int age;
    private String name;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Student(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public Student() {
    }
//此时重写的是Object类的toString()方法，直接输出对象，默认直接返回地址值
    /*@Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }*/

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }
//重写clong方法，否则无法调用
    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
